﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LED_Tester
{
    public partial class frmChangeCode : Form
    {
        public frmChangeCode()
        {
            InitializeComponent();
        }

        private string code;

        public string Code
        {
            get { return code; }
            set { code = value; }
        }

        private void btnAccept_Click(object sender, EventArgs e)
        {
            if (txtOld.Text == string.Empty)
            {
                MessageBox.Show("请输入原密码！", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                if (txtOld.Text != code)
                {
                    MessageBox.Show("密码错误！", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    if (txtNew.Text == string.Empty || txtComfirm.Text == string.Empty)
                    {
                        MessageBox.Show("请输入新密码！", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    else
                    {
                        if (txtNew.Text != txtComfirm.Text)
                        {
                            MessageBox.Show("请保证两次密码相同！", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        else
                        {
                            code = txtNew.Text;

                            MessageBox.Show("修改成功！", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

                            DialogResult = DialogResult.OK;
                        }
                    }
                }
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }
    }
}
